var Type = {};

for (var i = 0, type; type = ['String', 'Array', 'Number'][i++]; ) {
  (function (type) {
    Type[ 'is' + type] = function ( obj ) {
      return Object.prototype.toString.call( obj ) === '[object '+ type +']';
    }
  })(type)
}

Type.isArray( [] ) // true;
Type.isString( 'str') // true;

///////////////////////////
var getSingle = function( fn ) {
  var ret;
  return function() {
    return ret || (ret = fn.apply(this, arguments));
  }
}

var getScript = getSingle(function() {
  return document.createElement('script');
})

var script1 = getScript();
var script2 = getScript();

console.log( script1 === script2 ); // true;